# Author: Chris Moyer <cmoyer@newstex.com>

import urllib, urllib2
import marajo
try:
	import json
except:
	import simplejson as json

class User(object):
	"""JanRain User class"""

	def __init__(self, token):
		values = {"apiKey": marajo.conf.get("janrain", "api_key"), "token": token}
		data = urllib.urlencode(values)
		req = urllib2.Request('https://rpxnow.com/api/v2/auth_info', data)
		janrain_response = urllib2.urlopen(req)
		janrain_data = json.loads(janrain_response.read())
		assert(janrain_data['stat'] == "ok")
		self.profile = janrain_data['profile']
		self.id = self.profile['identifier']
